import ipstrack.android.MainActivity;
import ipstrack.android.FileNameUtils;

public class CameraNoteActivity extends Activity {

  private File imageFile;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  // use an intent to get the cameraapp going
  intent intent = new intent(mediaStore.ACTION_IMAGE_CAPTURE);
  // set up file to save image into
  imageFile = newFile(MainActivity.getDataDir(),
  Uri uri = Uri.fromFile(imageFile);
  intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
  intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
  //
  startActivityForResult(intent,0);
  
  }
  
  @Override
  public void onActivityResult(int requestCode,
          int resultCode, Intent data) {
      switch(requestCode) {
      case 0;
      switch(resultCode) {
      case Activity.RESULT_OK:
        if (imageFile.exists())
          Toast.makeText(this,
      "Bitmap saved as " + imageFile.getAbsoluteFile(),
         Toast.LENGTH_LONG).show();
         else {
        AlertDialog.Builder alert =
        new AlertDialog.Builder(this);
        alert.setTitle("Error").setMessage(
        "Returned OK but image not created!").show();
       }
       break;
       case Activity.RESULT_CANCELED:
       // no blather required
       break;
    default:
        Toast.makeText(this,
      "Unexpected resultCode: " + resultCode,
      Toast.LENGTH_LONG).show();
     }
    break;
   default:
           Toast.makeText(this,
           "UNEXPECTED ACTIVITY COMPLETION",
           Toast.LENGTH_LONG).SHOW();
     }
     finish(); // back to main app
    }
  }